The phpyii framework is used in the project. today, I read the standard documentation github. comyiisoftyiiwikiCore-framework-code-style, which says: The php file only needs to start the label & amp; lt ;? Php do not end the tag? & Amp; gt; It seems
Remember that my tutor told us the php end tag during the training period? & Amp; gt; you can choose not to add it, and it is best not to add it. In some cases, it is necessary (forget what the situation is). What do you think of Daniel? [Ps: of
Project to be useful to the PHP yii framework, today read the canonical document
Https://github.com/yiisoft/yii/wiki/Core-framework-code-style
Inside it says: Php file just start tag
不要结束标签 ?>, 印象中好像有看到其他框架也这么说过, 貌似会更安全, 为什么, 哪里有相关介绍?
Reply
We often see that some PHP files in the code is only the start tag, and there is no end tag, then under what circumstances can not write this end tag, and under what circumstances must write? Let's take a look at 2 examples:The following code works
Under what circumstances can not write PHP's closed tag "?>", do not write PHP
In some PHP projects we often see that some PHP files in the code is only the start tag, but not the end tag, then under what circumstances can not write the end tag,
Remember before during the training, the instructor told us that the end tag of PHP?> can not be added, and it is best not to add, said in some cases is necessary (forget what is the case)
What do you think of Daniel?
[PS: Of course, in the case of
If the file content is pure PHP code, it is best to remove the PHP end tag at the end of the file. This avoids having to accidentally add a space or line break after the PHP end tag, which causes PHP to start outputting these blanks, and there is no
When PHP parses a file, it looks for the start
, the tag tells PHP to start and stop explaining the code in it. Parsing this way allows PHP to be embedded in a variety of documents that are ignored by the PHP parser in the case of anything other
When PHP parses a file, it looks for the start
, the tag tells PHP to start and stop explaining the code in it. Parsing this way allows PHP to be embedded in a variety of documents that are ignored by the PHP parser in the case of anything other
Under what circumstances can I leave the PHP closed tag "?> ", Leave php empty
In some PHP projects, we often see that the code in some PHP files only has the start tag but not the end tag. Under what circumstances can this end tag be left blank,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.